﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpComm;

namespace DAL.Enums
{
    #region 管理员日记
    /// <summary>
    /// 日记信息类型
    /// </summary>
    public class emAdmLogAction : MyEnum<byte>
    {
        public static readonly emAdmLogAction All = new emAdmLogAction(0, "所有日记信息");
        public static readonly emAdmLogAction ChangerMyInfo = new emAdmLogAction(1, "修改自己信息");
        public static readonly emAdmLogAction LogOn = new emAdmLogAction(1, "修改自己信息");

        /// <summary>
        /// 自动生成List
        /// </summary>
                private static List<emAdmLogAction> _Items;
                public static List<emAdmLogAction> Items
                {
                    get
                    {
                        if (_Items == null)
                        {
                            var _Type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
                            _Items =
                                _Type.GetFields().Where(field => field.FieldType == _Type).Select(
                                    field => (emAdmLogAction)field.GetValue(null)).ToList();
                        }
                        return _Items;
                    }
                }

        public static emAdmLogAction Get(byte type)
        {
            return Items.SingleOrDefault(p => p.Value == type);
        }

        public static emAdmLogAction Get(string descript)
        {
            return Items.SingleOrDefault(p => p.Text == descript);
        }

        //私有构造函数,有效阻止在类型外部生成实例
        private emAdmLogAction(byte value, string text)
        {
            _Value = value;
            _Text = text;
        }

    }
    #endregion
}
